Release 10.1A: OpenEdge Development:
Programming Interfaces
Sharing streams among procedures
In some cases, you might want two or more procedures to share the same input or output streams. The following procedures,
i-sstrm.pandi-dispho.p, share the same output stream, phonelist. Notice that phonelist is defined as a shared stream in both procedures:
The
i-sstrm.pprocedure defines aNEWSHAREDSTREAMcalled phonelist. The procedure sends the output from the phonelist stream to a file calledphonefile. The procedure also calls thei-dispho.pprocedure:
The
Note: You cannot define or access shared streams in a persistent procedure. If you do, Progress returns a run-time error when you create the persistent procedure. For more information, see the chapter on persistent procedures in OpenEdge Development: Progress 4GL Handbook .i-dispho.pprocedure defines theSHAREDSTREAMphonelist, and displays the information from that stream on the screen. (It is more efficient to place theFOREACHandDISPLAYstatements in thei-sstrm.pprocedure. They are in a separate procedure here to illustrate shared streams.)Sharing streams is much like sharing variables:
- You use a regular
DEFINESTREAMstatement to define a stream that is available only to the current procedure.- To define a shared stream, you define the stream as
NEWSHAREDin the procedure that creates the stream, and asSHAREDin all other procedures that use that stream. If you do not explicitly close the stream, Progress closes it automatically at the end of the procedure in which you defined it.- You define the stream as
NEWGLOBALwhen you want that stream to remain available even after the procedure that contains theDEFINENEWGLOBALSHAREDSTREAMstatement ends.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |